From a1e6d8923c5d16ac1d7a10fcd09eab50b0501de7 Mon Sep 17 00:00:00 2001 From: Wei Liu Date: Thu, 23 Jul 2015 08:59:06 +0100 Subject: [PATCH] xl: check json string is not null before printing in create_domain Signed-off-by: Wei Liu Acked-by: Ian Campbell --- tools/libxl/xl_cmdimpl.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c index 9027acba81..a38074fabd 100644 --- a/tools/libxl/xl_cmdimpl.c +++ b/tools/libxl/xl_cmdimpl.c @@ -2781,6 +2781,11 @@ static uint32_t create_domain(struct domain_create *dom_info) printf_info_sexp(-1, &d_config, cfg_print_fh); } else { char *json = libxl_domain_config_to_json(ctx, &d_config); + if (!json) { + fprintf(stderr, + "Failed to convert domain configuration to JSON\n"); + exit(1); + } fputs(json, cfg_print_fh); free(json); flush_stream(cfg_print_fh); -- 2.30.2